SlideShare a Scribd company logo
1 of 23
BNAT Hijacking Repairing Broken Communication Channels Jonathan Claudius Rio Hotel and Casino August 5th, 2011 DefconSkytalk 2011 Security Begins with Trust
Quick Story “Easier Said Than Done…”
AGENDA Introduction What & How of BNAT BNAT Handshake/Hijack Demo of BNAT-Suite Finding BNAT (Active Identification) Attacking BNAT (Hijack BNAT Session) Conclusions
BNAT: The What? DST: 1.1.2.1 SRC: 1.1.2.2 Client “Cloud”
BNAT: The How? “On a Stick” Firewall 1.1.2.1 DNAT SNAT 1.1.2.2 Server Client
BNAT: The How? “A Loop” Firewall DNAT 1.1.2.1 Server Client Router 1.1.2.2 SNAT
The Bottom Line Outside view is the same… BNAT Loop ~= BNAT on a Stick …but both are still broken
BNAT Handshake Idea What if I could complete the TCP Handshake?
BNAT Handshake Idea What would it take? Stop “RST” Packet Accept “SYN/ACK” Send “ACK”
Tools Ruby Packetfu Gem Created by TodBeardsley (@todb) Used by MetasploitFramework IPTables Program to configure Linux Kernel Firewall
#1: Stop the “RST”  IPTables can do this quite easily… iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP No more RST 
#2: Accept  “SYN/ACK” Capture “SYN/ACK” Code cap = PacketFu::Capture.new(:iface => ARGV[0], :start => true, :filter => "tcp and src 1.1.2.2 and dst1.1.2.3") loop {cap.stream.each{ |pkt| packet = PacketFu::Packet.parse(pkt)  if packet.tcp_flags.syn == 1 and packet.tcp_flags.ack == 1  puts "got the syn/ack“  end } }
#3: Send“ACK” Build and Send “ACK” Code ackpkt = TCPPacket.new ackpkt.ip_saddr=synackpkt.ip_daddr ackpkt.ip_daddr="1.1.2.2“ ackpkt.eth_saddr="00:0c:29:af:cc:63“ ackpkt.eth_daddr="00:11:93:d0:e9:e0“ ackpkt.tcp_sport=synackpkt.tcp_dport ackpkt.tcp_dport=synackpkt.tcp_sport ackpkt.tcp_flags.syn=0  ackpkt.tcp_flags.ack=1 ackpkt.tcp_ack=synackpkt.tcp_seq+1 ackpkt.tcp_seq=synackpkt.tcp_ack ackpkt.tcp_win=183 ackpkt.recalc injack = PacketFu::Inject.new(:iface => ARGV[0]) injack.a2w(:array => [ackpkt.to_s]) puts "sent the ack"
End Result OUTSIDE INSIDE Firewall DNAT 1.1.2.1 SYN SYN SYN/ACK SYN/ACK Server Client ACK ACK 1.1.2.2 SNAT Router
BNAT Hijacking Idea What if I could weaponize this to do more?
BNAT-Suite I built some tools to help… BNAT-PCAP (Offline PCAP Analysis Tool) BNAT-SCAN (Active Scanning Tool) BNAT-ROUTER (Hijacking Router)
DEMO #1: Find BNAT bnat-scan.rb Perspective: External Penetration Test Discover the hidden service
DEMO #2: Attack BNAT bnat-router.rb Perspective: External Penetration Test Use the newly discovered service
End Result OUTSIDE INSIDE Firewall DNAT 1.1.2.1 B-Router SYN SYN SYN/ACK SYN/ACK Server ACK ACK 1.1.2.2 SNAT Router Client
Conclusions Understand the Gaps… Port/Vulnerability Scanners Dynamic Routing Vendor Limitations/Recommendations Incomplete NAT/SPI Implementations Security vs. Networking  Order & Flow Matter!!!
What's Next? Add support for… IPv6 BNAT UDP BNAT IP + Port TCP BNAT IP + Seq TCP BNAT IP + Port + Seq TCP BNAT
Questions?
Some Info/Ref… Where to get this code? https://github.com/claudijd/BNAT-Suite How to find me? Name: Jonathan Claudius City: Chicago, IL Email: jclaudius@trustwave.com Twitter: @claudijd References http://code.google.com/p/packetfu/ http://www.netfilter.org/ http://blog.thc.org/index.php?/archives/2-Port-Scanning-the-Internet.html http://en.wikipedia.org/wiki/Iptables http://en.wikipedia.org/wiki/Network_address_translation http://en.wikipedia.org/wiki/Transmission_Control_Protocol https://cocktails365.files.wordpress.com/2010/04/barnapkin.jpg

More Related Content

Similar to BNAT Hijacking: Repairing Broken Communication Channels

Layer one 2011-gh0stwood-d-dos-attacks
Layer one 2011-gh0stwood-d-dos-attacksLayer one 2011-gh0stwood-d-dos-attacks
Layer one 2011-gh0stwood-d-dos-attacks
fangjiafu
 
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdfOf the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
anuradhasilks
 
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
Christian Hallqvist
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)
NYversity
 
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 FinalExploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
masoodnt10
 

Similar to BNAT Hijacking: Repairing Broken Communication Channels (20)

Layer one 2011-gh0stwood-d-dos-attacks
Layer one 2011-gh0stwood-d-dos-attacksLayer one 2011-gh0stwood-d-dos-attacks
Layer one 2011-gh0stwood-d-dos-attacks
 
WebRTC: A front-end perspective
WebRTC: A front-end perspectiveWebRTC: A front-end perspective
WebRTC: A front-end perspective
 
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdfOf the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
 
Ghl systems net matrix terminal line encryption 2009 2010
Ghl systems net matrix terminal line encryption 2009 2010Ghl systems net matrix terminal line encryption 2009 2010
Ghl systems net matrix terminal line encryption 2009 2010
 
DIY Internet: Snappy, Secure Networking with MinimaLT (JSConf EU 2013)
DIY Internet: Snappy, Secure Networking with MinimaLT (JSConf EU 2013)DIY Internet: Snappy, Secure Networking with MinimaLT (JSConf EU 2013)
DIY Internet: Snappy, Secure Networking with MinimaLT (JSConf EU 2013)
 
TCP and Mobile Networks Turbulent Relationship
TCP and Mobile Networks Turbulent RelationshipTCP and Mobile Networks Turbulent Relationship
TCP and Mobile Networks Turbulent Relationship
 
L2 Attacks.pdf
L2 Attacks.pdfL2 Attacks.pdf
L2 Attacks.pdf
 
How to bypass an IDS with netcat and linux
How to bypass an IDS with netcat and linuxHow to bypass an IDS with netcat and linux
How to bypass an IDS with netcat and linux
 
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
IDS-ETHZ - NSG-IDS-REPORTING_of_year_2015
 
Time Sensitive Networking in the Linux Kernel
Time Sensitive Networking in the Linux KernelTime Sensitive Networking in the Linux Kernel
Time Sensitive Networking in the Linux Kernel
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)
 
VoiceBootcamp Ccnp collaboration lab guide v1.0 sample
VoiceBootcamp Ccnp collaboration lab guide v1.0 sampleVoiceBootcamp Ccnp collaboration lab guide v1.0 sample
VoiceBootcamp Ccnp collaboration lab guide v1.0 sample
 
R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1R bernardino hand_in_assignment_week_1
R bernardino hand_in_assignment_week_1
 
Nat traversal in WebRTC context
Nat traversal in WebRTC contextNat traversal in WebRTC context
Nat traversal in WebRTC context
 
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 FinalExploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
Exploiting Network Protocols To Exhaust Bandwidth Links 2008 Final
 
WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...
WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...
WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...
 
Challenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of viewChallenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of view
 
Software Defined Data Centers - June 2012
Software Defined Data Centers - June 2012Software Defined Data Centers - June 2012
Software Defined Data Centers - June 2012
 
Routers Firewalls And Proxies - OH MY!
Routers Firewalls And Proxies - OH MY!Routers Firewalls And Proxies - OH MY!
Routers Firewalls And Proxies - OH MY!
 
TLS Interception considered harmful (Chaos Communication Camp 2015)
TLS Interception considered harmful (Chaos Communication Camp 2015)TLS Interception considered harmful (Chaos Communication Camp 2015)
TLS Interception considered harmful (Chaos Communication Camp 2015)
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

BNAT Hijacking: Repairing Broken Communication Channels

  • 1. BNAT Hijacking Repairing Broken Communication Channels Jonathan Claudius Rio Hotel and Casino August 5th, 2011 DefconSkytalk 2011 Security Begins with Trust
  • 2. Quick Story “Easier Said Than Done…”
  • 3. AGENDA Introduction What & How of BNAT BNAT Handshake/Hijack Demo of BNAT-Suite Finding BNAT (Active Identification) Attacking BNAT (Hijack BNAT Session) Conclusions
  • 4. BNAT: The What? DST: 1.1.2.1 SRC: 1.1.2.2 Client “Cloud”
  • 5. BNAT: The How? “On a Stick” Firewall 1.1.2.1 DNAT SNAT 1.1.2.2 Server Client
  • 6. BNAT: The How? “A Loop” Firewall DNAT 1.1.2.1 Server Client Router 1.1.2.2 SNAT
  • 7. The Bottom Line Outside view is the same… BNAT Loop ~= BNAT on a Stick …but both are still broken
  • 8. BNAT Handshake Idea What if I could complete the TCP Handshake?
  • 9. BNAT Handshake Idea What would it take? Stop “RST” Packet Accept “SYN/ACK” Send “ACK”
  • 10. Tools Ruby Packetfu Gem Created by TodBeardsley (@todb) Used by MetasploitFramework IPTables Program to configure Linux Kernel Firewall
  • 11. #1: Stop the “RST” IPTables can do this quite easily… iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP No more RST 
  • 12. #2: Accept “SYN/ACK” Capture “SYN/ACK” Code cap = PacketFu::Capture.new(:iface => ARGV[0], :start => true, :filter => "tcp and src 1.1.2.2 and dst1.1.2.3") loop {cap.stream.each{ |pkt| packet = PacketFu::Packet.parse(pkt) if packet.tcp_flags.syn == 1 and packet.tcp_flags.ack == 1 puts "got the syn/ack“ end } }
  • 13. #3: Send“ACK” Build and Send “ACK” Code ackpkt = TCPPacket.new ackpkt.ip_saddr=synackpkt.ip_daddr ackpkt.ip_daddr="1.1.2.2“ ackpkt.eth_saddr="00:0c:29:af:cc:63“ ackpkt.eth_daddr="00:11:93:d0:e9:e0“ ackpkt.tcp_sport=synackpkt.tcp_dport ackpkt.tcp_dport=synackpkt.tcp_sport ackpkt.tcp_flags.syn=0 ackpkt.tcp_flags.ack=1 ackpkt.tcp_ack=synackpkt.tcp_seq+1 ackpkt.tcp_seq=synackpkt.tcp_ack ackpkt.tcp_win=183 ackpkt.recalc injack = PacketFu::Inject.new(:iface => ARGV[0]) injack.a2w(:array => [ackpkt.to_s]) puts "sent the ack"
  • 14. End Result OUTSIDE INSIDE Firewall DNAT 1.1.2.1 SYN SYN SYN/ACK SYN/ACK Server Client ACK ACK 1.1.2.2 SNAT Router
  • 15. BNAT Hijacking Idea What if I could weaponize this to do more?
  • 16. BNAT-Suite I built some tools to help… BNAT-PCAP (Offline PCAP Analysis Tool) BNAT-SCAN (Active Scanning Tool) BNAT-ROUTER (Hijacking Router)
  • 17. DEMO #1: Find BNAT bnat-scan.rb Perspective: External Penetration Test Discover the hidden service
  • 18. DEMO #2: Attack BNAT bnat-router.rb Perspective: External Penetration Test Use the newly discovered service
  • 19. End Result OUTSIDE INSIDE Firewall DNAT 1.1.2.1 B-Router SYN SYN SYN/ACK SYN/ACK Server ACK ACK 1.1.2.2 SNAT Router Client
  • 20. Conclusions Understand the Gaps… Port/Vulnerability Scanners Dynamic Routing Vendor Limitations/Recommendations Incomplete NAT/SPI Implementations Security vs. Networking  Order & Flow Matter!!!
  • 21. What's Next? Add support for… IPv6 BNAT UDP BNAT IP + Port TCP BNAT IP + Seq TCP BNAT IP + Port + Seq TCP BNAT
  • 23. Some Info/Ref… Where to get this code? https://github.com/claudijd/BNAT-Suite How to find me? Name: Jonathan Claudius City: Chicago, IL Email: jclaudius@trustwave.com Twitter: @claudijd References http://code.google.com/p/packetfu/ http://www.netfilter.org/ http://blog.thc.org/index.php?/archives/2-Port-Scanning-the-Internet.html http://en.wikipedia.org/wiki/Iptables http://en.wikipedia.org/wiki/Network_address_translation http://en.wikipedia.org/wiki/Transmission_Control_Protocol https://cocktails365.files.wordpress.com/2010/04/barnapkin.jpg